function initAllPlan() {
    $("body").on('click', '.attention_plan_bt li', function () {
        $(this).addClass("current").siblings().removeClass("current");
        var para = $(this).attr('data-type');
        var html = '';
        var dept_id = $('input[name="dept_id"]').val();
        var url = 'allPlan/para/' + para;
        if (dept_id > 0) {
            url = 'allPlan/para/' + para + '/dept_id/' + dept_id;
        } else {
            url = 'allPlan/para/' + para;
        }
        $.ajax({
            url: url,
            type: 'get',
            success: function (res) {
                console.log(res)
                if (res.length > 0) {
                    for (var i = 0; i < res.length; i++) {
                        html += '<li><a class="planInfo pointer" data-id="' + res[i].plan_id + '" data-dept="' + res[i].plan_id + '"';
                        if (res[i].end_date < res[i].today && (res[i].end_date != '0000-00-00')) {
                            html += ' style="color:#ED8D76"'
                        }
                        html += '><span class="plan_nr">' + (i + 1) + '.' + res[i].name;
                        if (res[i].noRead == 1) {
                            html += '<span class="readFlag"></span>';
                        }
                        html += '</span><span class="plan_att_num">' + res[i].total_percent + '%';
                        html += '</span></a><span class="collect"><a href="#"><i class="icon-guanzhu" data-id="' + res[i].plan_id + '"></i></a></span></li>';
                    }
                } else {
                    html += '<li><a href="#"><span class="plan_nr">暂无数据</span></a></li></ul>'
                }
                $('.new_plan_lists').html(html);
            }
        })
    });

    //
    $("body").on('click', '.idTabs li', function () {
        $(this).addClass("allday").siblings().removeClass("allday");
        var dept_para = $(this).attr('data-id');
        var url = 'deptPlan/para/' + dept_para;
        var html = '';
        var htmlHeader = '';

        $.ajax({
            url: url,
            type: 'get',
            success: function (res) {
                console.log(res);
                var cateHtml = '';
                cateHtml += '<li class="pointer current noread_flag" data-type="0"><span>' + res.total + '</span><br/>全部';
//                if(res.allNoRead == 1){
//                    cateHtml += '<span class="readFlag countFlag"></span>';
//                }
                cateHtml += '</li>';
                for (var i = 0; i < res.count.length; i++) {
                    cateHtml += '<li class="pointer noread_flag ';
                    if (i == 0) {
                        cateHtml += '';
                    }
                    cateHtml += '" data-type="' + res.count[i].type_id + '">';
                    cateHtml += '<span>' + res.count[i].count + '</span><br/>' + res.count[i].type_name;
                    if (res.count[i].noRead == 1) {
                        cateHtml += '<span class="readFlag countFlag"></span>';
                    }
                    cateHtml += '</li>';
                }
                cateHtml += '<input type="hidden" name="dept_id" value="' + dept_para + '">';
                $('.attention_plan_bt').html(cateHtml);

                var html = '';
                if (res.plans.length > 0) {
                    for (var i = 0; i < res.plans.length; i++) {
                        html += '<li><a class="planInfo pointer" data-id="' + res.plans[i].plan_id + '" data-dept="' + res.plans[i].plan_id + '"';
                        if (res.plans[i].end_date < res.plans[i].today && (res.plans[i].end_date != '0000-00-00')) {
                            html += ' style="color:#ED8D76"'
                        }
                        html += '><span class="plan_nr">' + (i + 1) + '.' + res.plans[i].name;
                        if (res.plans[i].noRead == 1) {
                            html += '<span class="readFlag"></span>';
                        }
                        html += '</span><span class="plan_att_num">' + res.plans[i].total_percent + '%';
                        html += '</span></a><span class="collect"><a href="#"><i class="icon-guanzhu" data-id="' + res.plans[i].plan_id + '"></i></a></span></li>';
                    }
                } else {
                    html += '<li><a href="#"><span class="plan_nr">暂无数据</span></a></li></ul>'
                }
                $('.new_plan_lists').html(html);
            }
        })
    })

    $('.history').on('click', function () {
        layer.open({
            type: 2,
            title: [
                "选择月份",
                'background-color: #437dba;color:#fff;text-align:center;font-size:1em;',
            ],
            area: ['80%', '80%'], //宽高
            offset: ['20px', '10%'], //弹出位置 [top,left]
            content: "/index.php/Index/Index/layer/type/10"
        })
    })


}

function initFollowPlan() {
    $("body").on('click', '.attention_plan_bt li', function () {
        $(this).addClass("current").siblings().removeClass("current");
        var para = $(this).attr('data-type');
        var url = 'follow/para/' + para;
        var html = '';

        $.ajax({
            url: url,
            type: 'get',
            success: function (res) {
                console.log(res)
                html += '<ul class="new_plan_lists">';
                if (res.length > 0) {
                    for (var i = 0; i < res.length; i++) {
                        html += '<li><a class="planInfo pointer" data-id="' + res[i].plan_id + '" data-dept="' + res[i].plan_id + '"';
                        if (res[i].end_date < res[i].today && (res[i].end_date != '0000-00-00')) {
                            html += ' style="color:#ED8D76"'
                        }
                        html += '><span class="plan_nr">' + (i + 1) + '.' + res[i].name + '</span>';
                        
//                        html += '<li><a href="show/id/' + res[i].plan_id + '">';
//                        html += '<span class="plan_nr">' + (i + 1) + '.' + res[i].name + '</span>';
                        html += '<span class="plan_att_num">' + res[i].total_percent + '%</span></a>';
                        html += '<span class="collect"><i class="icon-guanzhu2 pointer cancelAtten" data-id="' + res[i].plan_id + '"></i></span></li>';
                    }
                } else {
                    html += '<li><a href="#"><span class="plan_nr">暂无数据</span></a></li></ul>'
                }
                html += '</ul>';
                $('.st-panel').html(html);
            }
        })
    });

    $('body').on('click', '.cancelAtten', function () {
        var id = $(this).attr('data-id');
        var url = $('#cancelAttenUrl').val();
        $.get(url + '?id=' + id, function (res) {
            console.log(res)
            if (res.status) {
                layer.msg(res.msg);
                setTimeout("location.reload()", 2000);
            } else {
                layer.msg(res.msg);
            }
        })
    })
}

function initFollow() {
    $('body').on('click', '.icon-guanzhu', function () {
        var plan_id = $(this).attr('data-id');
        var url = $('#followUrl').val() + '?plan_id=' + plan_id;
        $.get(url, function (res) {
            console.log(res);
            layer.msg(res.msg);
            setTimeout("location.reload()", 2000);
        })
    })


}
